import { ref } from 'vue';
import { getDepts, getRoles, getBtnList } from '@/config/api.js'
import iconfont from '@/assets/iconfont/iconfont.json'

//自定义列表序号
export const indexMethod = (index) => {
    return index+1;
}

//获取系统部门
export const getSysDepts = async (kind) => {
    const data = ref({
        kind: kind
    })
    const list = ref([])
    //执行查询数据
    await getDepts(data.value).then(res => {
        list.value = res.data
    })
    return list.value
}

//获取系统角色
export const getSysRoles = async (kind) => {
    const data = ref({
        kind: kind
    })
    const list = ref([])
    //执行查询数据
    await getRoles().then(res => {
        list.value = res.data
    })
    return list.value
}

//获取按钮权限
export const getBtns = async (path) => {
    let data = {
        path: path
    }
    const btns = ref([])
    await getBtnList(data).then(res => {
        btns.value = res.data
    })
    return btns.value
}

export const getIconfonts = () => {
    return iconfont.glyphs
}

